package org.example.bean;

/**
 * @Description 1比1的地图坐标格子
 * @Author yanghongjun
 * @Date 2024/5/26 下午6:22
 * @Version 1.0
 */
public class Grid {
    /**
     * 格子类型 0正常格子 1静态阻挡格子 2关卡连接点 3关卡
     */
    private int type;
    /**
     * 行 列
     */
    private int row, col;
    /**
     * 最大和最小的x轴 y轴
     */
    private int minX, maxX, minY, maxY;
    /**
     * 所属疆域id
     */
    private int territory;
    /**
     * 所属关卡id（关卡连接点和关卡）
     */
    private long passId;
    /**
     * 疆域是否开放
     */
    private boolean openTerritory = false;
    /**
     * 是否完全阻挡
     */
    private boolean stopBlock = false;

    public Grid() {
    }

    public Grid(int row, int col, int minX, int maxX, int minY, int maxY) {
        this.row = row;
        this.col = col;
        this.minX = minX;
        this.maxX = maxX;
        this.minY = minY;
        this.maxY = maxY;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getRow() {
        return row;
    }

    public int getCol() {
        return col;
    }

    public int getMinX() {
        return minX;
    }

    public int getMaxX() {
        return maxX;
    }

    public int getMinY() {
        return minY;
    }

    public int getMaxY() {
        return maxY;
    }

    public boolean isStopBlock() {
        return stopBlock;
    }

    public void setStopBlock(boolean stopBlock) {
        this.stopBlock = stopBlock;
    }

    public int getTerritory() {
        return territory;
    }

    public void setTerritory(int territory) {
        this.territory = territory;
    }

    public boolean isOpenTerritory() {
        return openTerritory;
    }

    public void setOpenTerritory(boolean openTerritory) {
        this.openTerritory = openTerritory;
    }

    public long getPassId() {
        return passId;
    }

    public void setPassId(long passId) {
        this.passId = passId;
    }

    /**
     * 获取格子的中心坐标。
     *
     * @return 一个包含两个元素的数组，第一个元素是中心的X坐标，第二个元素是中心的Y坐标。
     */
    public int[] getCenter() {
        int centerX = (minX + maxX) / 2;
        int centerY = (minY + maxY) / 2;
        return new int[]{centerX, centerY};
    }

}
